function Dinosaur() {
  this.x = 150;
  this.y =  sence.height - 110;
  this.w = 87;
  this.h = 96; 
  this.ctx = ctx;
  this.index = 0;
  this.b = -1;
  this.sx = 1855;
  this.sy = 0;
  this.v0 = 13;
  this.t = 0;
  this.statu = 0; // 0 正常 1 跳跃  2 趴下  
  this.collisionList = DinosaurCollisionList;
  this.red = true;

}
// Dinosaur
Dinosaur.info = {
  x: 1855,
  y: 0,
  width: 88,
  height:96
}
 



Dinosaur.prototype = {

  draw() {
    // console.log('this.red:', this.red);
    // 切换恐龙 
    this.index++;
    if (this.index %9 === 0 && this.statu != 1) {
      this.b = - this.b;
      this.sx += this.b * 88;
    }
    // 自由落体 
    if (this.t!==0 && this.y <=  sence.height - 110) {
      let t = (Date.now() - this.t )/1000;
      let vt = this.v0 - 30 * t;
      this.y -= vt;    
    }

    if ( this.y >= sence.height - 110 ) {
      this.y  = sence.height - 110;
      this.statu = 0;
    }
    if (this.red) {
      this.ctx.strokeStyle = 'red'
    } else {
      this.ctx.strokeStyle = 'pink'
    }

    this.ctx.drawImage(imgSprite, this.sx, this.sy, this.w, this.h, this.x, this.y, this.w, this.h);
    this.ctx.lineWidth = 0.5;
    // this.ctx.strokeStyle = 'red';

    // this.ctx.strokeRect(this.x, this.y, this.w, this.h);
    // 绘制碰撞盒子
    this.collisionList.forEach(v=> {
      // this.ctx.strokeRect(this.x + v.x, this.y+v.y, v.w, v.h);
    })

    this.ctx.beginPath();

  },

  jump() {
    this.t = Date.now();   
    this.statu = 1; 
  }
}